<?php
/**
 * Object Relational Persistence Mapping Class for table: pha_ewh_pick_drug
 *
 * @package	modules.dept_pharmacy.ordo
 * @author	viethd
 * @version $
 * @copyright 2009 LHV Company
 */
class PhaEwhPickDrug extends ORDataObject {

    /**#@+
     * Fields of table: pha_ewh_pick_drug mapped to class members
     */
    var $pha_ewh_pick_drug_id		= '';
    var $pha_ewh_exticket_detail_id		= '';
    var $pha_ewh_imticket_detail_id		= '';
    var $quantity		= '';
    /**#@-*/


    /**
     * DB Table
     */
    var $_table = 'pha_ewh_pick_drug';

    /**
     * Primary Key
     */
    var $_key = 'pha_ewh_pick_drug_id';

    /**
     * Internal Name
     */
    var $_internalName = 'PhaEwhPickDrug';

    /**
     * Handle instantiation
     */
    function __construct() {
        parent::ORDataObject();
    }

    public function setData($data =array()) {
        if (is_array($data)) {
            $this->populateArray($data);
        }
    }

    public function deleteItemByEDId($phaEwhExticketDetailId) {
         
        $sql = "DELETE FROM $this->_table WHERE pha_ewh_exticket_detail_id='$phaEwhExticketDetailId'";
        $this->_execute($sql);

    }
    
    

    public function listItemOfGivenExticketDetail($exTicketDetailId) {
        $ds =& new Datasource_sql();
        $sql = array(
               'cols'  => "pha_ewh_pick_drug_id, pha_ewh_imticket_detail_id, quantity",
               'from'  => "$this->_table t INNER JOIN pha_ewh_exticket_detail peed
                            ON (t.pha_ewh_exticket_detail_id=peed.pha_ewh_exticket_detail_id
                                                     AND t.pha_ewh_exticket_detail_id='$exTicketDetailId')"
        );
        $ds->setup($this->_db, $sql);
        $result = $ds->toArray();
        return $result;
    }

}
?>
